package com.cq.xjms.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 学院实体类
 * @author caiqiang
 * @version 1
 */
@Entity
@Table(name="Institute")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries( {
	@NamedQuery(name = "Institute.list", query ="select i from Institute i order by i.id"),
	@NamedQuery(name = "Institute.query", query ="select i from Institute i where i.code=:code"),
	@NamedQuery(name = "Institute.queryById", query ="select i from Institute i where i.id=:id")
})
public class Institute extends BaseEntity
{
	public static final String INSTITUTE_LIST = "Institute.list";
	public static final String INSTITUTE_QUERY = "Institute.query";
	public static final String INSTITUTE_QUERYBYID = "Institute.queryById";
	private static final long serialVersionUID = 1539350453366775796L;
	
	@Column(name ="NAME",length=20,nullable = false)
	private String name;
	
	
	@Column(name = "CODE",length=10)
	private String code;
	
	@OneToMany(fetch = FetchType.LAZY,mappedBy= "institute")
	private List<Department> departments;


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public List<Department> getDepartments() {
		return departments;
	}


	public void setDepartments(List<Department> departments) {
		this.departments = departments;
	}

}
